package com.robot.dao.action;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.robot.dao.entity.ActionUnit;
import lombok.*;

import java.io.IOException;
import java.io.Serializable;


@Data
@NoArgsConstructor
@AllArgsConstructor
// 有action_unit的基本属性，只是定制了detail
// 文本对话大模型组件的repo层对象，可以在业务代码中流转
public class ActionUnitAiBigModel extends ActionUnit {
    private BigModelDetail detail;
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class BigModelDetail implements Serializable {
        private Integer bigModelType;
        private String bigModelName;
        private String characterSetting;
    }
    private final ObjectMapper objectMapper = new ObjectMapper();

    public void setDetail(BigModelDetail detail) {
        this.detail = detail;
        String jsonDetail;
        try {
            jsonDetail = objectMapper.writeValueAsString(detail);
        } catch (IOException e) {
            // 处理转换失败的异常情况
            e.printStackTrace();
            return;
        }
        super.setDetail(jsonDetail);
    }

    public String getDetail() {
        return super.getDetail();
    }
    public BigModelDetail getStructDetail() {
        return this.detail;
    }

}
